home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sources.misc
- subject: v09i002: rndname3: Random Name Generator for RPGs, Version 3.0
- From: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
- Reply-To: slocum@hi-csc.UUCP
-
- Posting-number: Volume 9, Issue 2
- Submitted-by: slocum@hi-csc.UUCP
- Archive-name: rndname3
-
- This is version 3.0 of my rndname program. The major addition
- to this program is the inclusion of the Scrabble (tm) letter
- distribution, as well as the previous flat distribution.
- By adding the -DSCRABBLE switch in the Makefile, the program
- is generated with these distributions.
-
- Please send me any comments or modifications you have.
- ---
- Brett Slocum, Honeywell SSDC, Golden Valley, Minnesota
- <uunet!hi-csc!slocum> | AIDS is a virus; George Bush
- or <hi-csc!slocum@uunet.uu.net> | is a punishment from God.
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 1 (of 1)."
- # Contents: Makefile README README.v1 name.c names.csh names.sh
- # Wrapped by slocum@merlin on Tue Nov 7 18:14:20 1989
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'Makefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Makefile'\"
- else
- echo shar: Extracting \"'Makefile'\" \(476 characters\)
- sed "s/^X//" >'Makefile' <<'END_OF_FILE'
- X# makefile for name.c
- X#
- X# Comment out the BSD line if you're on System V
- X# Comment out the SYSV line if you're using Berkely Unix.
- X# Comment out both lines if you're using Microsoft C with MS-DOS.
- X#
- X# Uncomment the DIST = -DSCRABBLE line, if you want to use the
- X# Scrabble (tm) distribution of letters.
- X
- X# SYSTEM = -DSYSV
- XSYSTEM = -DBSD
- X
- XDIST = -DSCRABBLE
- X#DIST =
- X
- XCFLAGS = -O $(SYSTEM) $(DIST)
- X
- Xname: name.c
- X cc -o name $(CFLAGS) name.c
- X
- END_OF_FILE
- if test 476 -ne `wc -c <'Makefile'`; then
- echo shar: \"'Makefile'\" unpacked with wrong size!
- fi
- chmod +x 'Makefile'
- # end of 'Makefile'
- fi
- if test -f 'README' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'README'\"
- else
- echo shar: Extracting \"'README'\" \(525 characters\)
- sed "s/^X//" >'README' <<'END_OF_FILE'
- XThis is version 3.0 of my rndname program. The major addition
- Xto this program is the inclusion of the Scrabble (tm) letter
- Xdistribution, as well as the previous flat distribution.
- XBy adding the -DSCRABBLE switch in the Makefile, the program
- Xis generated with these distributions.
- X
- XPlease send me any comments or modifications you have.
- X---
- XBrett Slocum, Honeywell SSDC, Golden Valley, Minnesota
- X<uunet!hi-csc!slocum> | AIDS is a virus; George Bush
- X or <hi-csc!slocum@uunet.uu.net> | is a punishment from God.
- X
- END_OF_FILE
- if test 525 -ne `wc -c <'README'`; then
- echo shar: \"'README'\" unpacked with wrong size!
- fi
- chmod +x 'README'
- # end of 'README'
- fi
- if test -f 'README.v1' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'README.v1'\"
- else
- echo shar: Extracting \"'README.v1'\" \(1157 characters\)
- sed "s/^X//" >'README.v1' <<'END_OF_FILE'
- XThis program is a very simple random name generator for use
- Xwith roleplaying games. It produces surprisingly good names
- Xfor the very simple method used. The names tend to be exotic,
- Xsince 'X' and 'Z' have the same chance of coming up as 'T' and
- X'N'. Many of the names have a Japanese or African flavor. Some
- Xof my favorites came in the first page generated: Zozaras, Lyxam,
- XRux, and Zelica.
- X
- XThe program 'name.c' produces the names, and two scripts are
- Xincluded to formats them into pages: names.csh and names.sh,
- Xfor C-shell and Bourne shell, respectively. Instructions for
- Xchanging the distribution of letters are given in comments in
- Xname.c.
- X
- XThese programs have been tested on an Apollo DN330 with both
- XBSD4.2 and Sys V, and on BSD4.3. The makefile and names.csh
- Xscript have Sys V versions commented out. The changes for
- XMS-DOS similar to the ones used here have been tested, but
- Xthe specific changes for MS-DOS in this program have not.
- X
- XSend any changes or updates to me:
- X
- XBrett Slocum UUCP: ...uunet!hi-csc!slocum
- X Arpa: hi-csc!slocum@uunet.uu.net
- X"My name is Inigo Montoya. You killed my father. Prepare to die."
- X
- END_OF_FILE
- if test 1157 -ne `wc -c <'README.v1'`; then
- echo shar: \"'README.v1'\" unpacked with wrong size!
- fi
- chmod +x 'README.v1'
- # end of 'README.v1'
- fi
- if test -f 'name.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'name.c'\"
- else
- echo shar: Extracting \"'name.c'\" \(4189 characters\)
- sed "s/^X//" >'name.c' <<'END_OF_FILE'
- X/**************************************************************************
- X * name - prints random names *
- X * Copyright 1988, 1989 by Brett Slocum. All rights reserved. *
- X * Permission is granted to distribute, modify, or use portions of this *
- X * code in other programs, as long as this notice remains intact. *
- X * This program or its derivatives may not be sold for profit without *
- X * permission. *
- X * *
- X * UNIX Version: Brett Slocum UUCP: ...uunet!hi-csc!slocum *
- X * ARPA: slocum@hi-csc.honeywell.com *
- X * Changes were suggested by Geoff Kimbrough <geoff@ism780c.isc.com> *
- X * *
- X * IBM Microsoft C v5.0 changes by Loyd Blankenship on 11-15-88 *
- X * UUCP: ...rutgers.edu!cs.utexas.edu!nth!loyd *
- X * *
- X * Version 2 by Brett Slocum 3/22/89 : various cleanups, features, etc. *
- X * *
- X * Version 3 by Brett Slocum 11/7/89 : Scrabble (tm) letter distribution *
- X * *
- X **************************************************************************/
- X
- X#ifdef SYSV
- X#include <string.h>
- X#define srandom srand48
- X#define random lrand48
- X#endif
- X
- X#ifdef BSD
- X#include <strings.h>
- X#endif
- X
- X#ifdef MSC
- X#include <string.h>
- X#include <stdio.h>
- X#include <stdlib.h>
- X#include <time.h>
- X#define srandom srand
- X#define random rand
- X#endif
- X
- X#include <ctype.h>
- X
- X#define YES 1
- X#define NO 0
- X#define MAXNAME 30
- X#define MINLENGTH 3
- X#define RANGE 6
- X#define rnd(n) (unsigned)(random() % (n))
- X
- X/*
- X Since "y" appears twice, once in each string; all other
- X letters, except "'", are doubled to keep the distribution even.
- X By adding or deleting the letters from these strings, you
- X can change the frequency of appearance of the letters,
- X (i.e. by adding an "e" and a "t" and deleting a "z" and a "q",
- X a distribution closer to English could be made.)
- X
- X Another set of strings has the Scrabble (tm) distributions of letters.
- X Put -DSCRABBLE into the Makefile, if you want the Scrabble (tm) distribution.
- X*/
- X
- X#define FLAT_VOWELS "aaeeiioouuy'"
- X#define FLAT_CONS "bbccddffgghhjjkkllmmnnppqqrrssttvvwwxxyzz'"
- X#define SCRABBLE_VOWELS "aaaaaaaaaeeeeeeeeeeeeiiiiiiiiioooooooouuuuy'"
- X#define SCRABBLE_CONS "bbccddddffggghhjkllllmmnnnnnnppqrrrrrrssssttttttvvwwxyz'"
- X
- X#ifdef SCRABBLE
- Xchar vowels[] = SCRABBLE_VOWELS;
- Xchar cons[] = SCRABBLE_CONS;
- X#else
- Xchar vowels[] = FLAT_VOWELS;
- Xchar cons[] = FLAT_CONS;
- X#endif
- X
- Xmain(argc, argv)
- Xint argc;
- Xchar *argv[];
- X{
- X int n, letters, vowel;
- X char name[MAXNAME];
- X
- X if (argc == 2) {
- X /* initialize random number generator */
- X srandom(time(0L));
- X
- X /* generate argv[1] names */
- X for (n = atoi(argv[1]); n > 0; n--) {
- X name[0] = '\0';
- X /* choose whether first character is a vowel */
- X vowel = (rnd(2) ? YES : NO);
- X /* get initial character - not " ' " */
- X if (vowel)
- X strncat(name, &vowels[rnd(sizeof(vowels) - 2)], 1);
- X else
- X strncat(name, &cons[rnd(sizeof(cons) - 2)], 1);
- X /* upper case first letter */
- X name[0] = _toupper(name[0]);
- X /* complete rest of letters */
- X for (letters = rnd(RANGE) + MINLENGTH; letters > 0; letters--) {
- X /* alternate vowels and consonants */
- X vowel = ( vowel ? NO : YES );
- X /* get next character */
- X if (vowel)
- X strncat(name, &vowels[rnd(sizeof(vowels)-1)], 1);
- X else
- X strncat(name, &cons[rnd(sizeof(cons)-1)], 1);
- X }
- X printf("%s\n", name);
- X }
- X }
- X else
- X printf("Usage: name number-of-names\n");
- X}
- X
- END_OF_FILE
- if test 4189 -ne `wc -c <'name.c'`; then
- echo shar: \"'name.c'\" unpacked with wrong size!
- fi
- chmod +x 'name.c'
- # end of 'name.c'
- fi
- if test -f 'names.csh' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'names.csh'\"
- else
- echo shar: Extracting \"'names.csh'\" \(398 characters\)
- sed "s/^X//" >'names.csh' <<'END_OF_FILE'
- X#! /bin/csh
- X# names - generate random names
- X#
- X# usage: names [pages]
- X# where 'pages' is how many pages of names you want. Default = 1 page.
- X
- Xif ($#argv == 0) then
- X @ n = 336
- Xelse
- X @ n = 336 * $1
- Xendif
- X
- X# BSD script -- uncomment this line if BSD
- Xname $n | sort -u | pr -6 | expand
- X
- X# sysv script -- uncomment this line if SYSV
- X# note: no tab expansion performed
- X
- X#name $n | sort -u | pr -6
- X
- END_OF_FILE
- if test 398 -ne `wc -c <'names.csh'`; then
- echo shar: \"'names.csh'\" unpacked with wrong size!
- fi
- chmod +x 'names.csh'
- # end of 'names.csh'
- fi
- if test -f 'names.sh' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'names.sh'\"
- else
- echo shar: Extracting \"'names.sh'\" \(94 characters\)
- sed "s/^X//" >'names.sh' <<'END_OF_FILE'
- Xif [ $# = 0 ]
- Xthen
- X n=`expr 336`
- Xelse
- X n=`expr 336 \* $1`
- Xfi
- Xname $n | sort -u | pr -6
- X
- END_OF_FILE
- if test 94 -ne `wc -c <'names.sh'`; then
- echo shar: \"'names.sh'\" unpacked with wrong size!
- fi
- chmod +x 'names.sh'
- # end of 'names.sh'
- fi
- echo shar: End of archive 1 \(of 1\).
- cp /dev/null ark1isdone
- MISSING=""
- for I in 1 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have the archive.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-
- --
- Brett Slocum <uunet!hi-csc!slocum>
- or <hi-csc!slocum@uunet.uu.net>
-
- There is something fascinating about science. One gets such wholesale
- returns of conjecture out of such a trifling investment of fact.
- -- Mark Twain
-
-